import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() {
  runApp(new MaterialApp(
      title: "App", theme: new ThemeData.light(), home: HomeScreen()));
}

class HomeScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return HomeScreenState();
  }
}

class HomeScreenState extends State<HomeScreen> {
  int _currentIndex = 0;
  List<ListView> _contents = <ListView>[
    ListView.builder(
      padding: EdgeInsets.fromLTRB(0, 8, 0, 8),
      itemBuilder: (BuildContext context, int index) {
        return InkWell(
            child: Padding(
                padding: EdgeInsets.all(8), child: Text("items $index")),
            onTap: () {
              Fluttertoast.showToast(msg: "haha");
            });
      },
      itemCount: 200,
      physics: AlwaysScrollableScrollPhysics(),
    ),
    ListView.builder(
      itemBuilder: (BuildContext context, int index) {
        return Text("controls");
      },
      itemCount: 200,
    )
  ];

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      floatingActionButton: new FloatingActionButton(onPressed: null),
      appBar: new AppBar(centerTitle: true, title: new Text("这是标题")),
      body: _contents[_currentIndex],
      bottomNavigationBar: new BottomNavigationBar(
        iconSize: 18,
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(icon: Icon(Icons.school), title: Text("布局")),
          BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("控件"))
        ],
        currentIndex: _currentIndex,
        type: BottomNavigationBarType.fixed,
        onTap: onTabSelected,
      ),
    );
  }

  onTabSelected(int index) {
    //Fluttertoast.showToast(msg: "index:$index");
    setState(() {
      _currentIndex = index;
    });
  }
}

/*switch (index) {
case 0:
showDialog(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return SimpleDialog(
title: Text("对话框标题"), children: <Text>[Text("1")]);
});
break;
case 1:
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text("标题"),
content: Text("你好啊"),
actions: <Widget>[
FlatButton(
child: Text("确定"),
onPressed: () {
Fluttertoast.showToast(msg: "click ok!!!");
Navigator.of(context).pop();
},
)
],
);
});
break;
}*/
